package fh.app4stud.mensa.adapters;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import fh.app4stud.mensa.costumeviews.MenuTypeOfFoodItem;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: iplese
 * Date: 04.04.11
 * Time: 22:23
 * Version 1.0
 * To change this template use File | Settings | File Templates.
 */
public class FoodItemAdapter extends ArrayAdapter<MenuTypeOfFoodItem> {

    int resource;

    public FoodItemAdapter(Context context, int textViewResourceId, List<MenuTypeOfFoodItem> objects) {
        super(context, textViewResourceId, objects);
        resource = textViewResourceId;
    }

    @Override
    public View getView(int postition, View convertView, ViewGroup parent) {
        LinearLayout itemView;

        MenuTypeOfFoodItem item = getItem(postition);

        String name = item.getName();
        String description = item.getDescription();
        ImageView imageView = item.getMenuImage();

        if (convertView == null) {
            itemView = new LinearLayout(getContext());
            String inflater = Context.LAYOUT_INFLATER_SERVICE;
            LayoutInflater vi = (LayoutInflater) getContext().getSystemService(inflater);
            vi.inflate(resource, itemView, true);
        } else
            itemView = (LinearLayout) convertView;

        //TODO     ne kuzim bas ovaj dio,  text string se stavlja u @strings? kad se skine s internta
        //        valjada zato treba da povezem instance s findViewById ....
        //TextView name = (TextView)itemView.findViewById(R.id.....)
        //TextView description = (TextView)itemView.findViewById(R.id.....)
        //ImageView image = (ImageView)itemView.findViewById(R.id.....)
        return itemView;
    }
}
